home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
shared.dir
/
03022_Script_BUTTON INDEX
< prev
next >
Wrap
Text File
|
1996-06-21
|
4KB
|
113 lines
-- -----------------------------------------------------------
-- Handler getVButtonIndexOffSet gets the index of the
-- button in the given vertical button bar.
on getVButtonIndexOffSet S, numDivisions, V
global OneButtonHeight
set OffSetTop = 3
set ButtonBarHeight = the height of sprite S
set OneButtonHeight = ButtonBarHeight/numDivisions + OffSetTop
set ButtonBarTop = (the top of sprite S)
-- the resulting segment index is 1-based
return ((V - ButtonBarTop) / OneButtonHeight) + 1
end
-- -----------------------------------------------------------
-- -----------------------------------------------------------
-- Handler getVButtonIndex gets the index of the
-- button in the given vertical button bar.
on getVButtonIndex S, numDivisions, V
global OneButtonHeight
set ButtonBarHeight = the height of sprite S
set OneButtonHeight = ButtonBarHeight/numDivisions
set ButtonBarTop = the top of sprite S
-- the resulting segment index is 1-based
return ((V - ButtonBarTop) / OneButtonHeight) + 1
end
-- ----------------------------------------------------------
-- Handler getHButtonIndex gets the index of the
-- button in the given horizontal button bar.
on getHButtonIndex S, numDivisions, H
set ButtonBarWidth = the width of sprite S
set OneButtonWidth = ButtonBarWidth / numDivisions
set ButtonBarLeft = the left of sprite S
-- the resulting segment index is 1-based
return ((H - ButtonBarLeft) / OneButtonWidth) + 1
end
-- -----------------------------------------------------------
-- Handler getVHButtonIndex gets the index of the
-- button in the given 2 dimensional button bar (assuming that
-- the numbers go down and then across).
on getVHButtonIndex buttonBar, numVItems, numHItems, V, H
set Hindex = getHButtonIndex(buttonBar,numHItems,H)
set Vindex = getVButtonIndex(buttonBar,numVItems,V)
return ((Hindex-1) * numVItems) + Vindex
end
--Handler ButtonClick
on buttonClick destination
puppetSprite the clickOn, TRUE
set clickedCast = the clickon
if clickedCast < 1 then exit
set CastNumber = the castNum of sprite clickedCast
set CastName = the name of cast CastNumber
set NumChars = the number of chars in CastName
if the last char of CastName = "n" then
set NewName = char 1 to (NumChars - 2) of CastName & "out"
else
set NewName = char 1 to (NumChars - 3) of CastName & "in"
end if
set the castNum of sprite clickedCast = cast NewName
updateStage
goSection destination
puppetSprite clickedCast, FALSE
updateStage
end
--Handler ButtonClickLife
on NextPageLife
puppetSprite the clickOn, TRUE
set CastNumber = the castNum of sprite the clickOn
set CastName = the name of cast CastNumber
set NumChars = the number of chars in CastName
set ShortChars = NumChars - 2
set NewName = char 1 to ShortChars of CastName & "in"
set the castNum of sprite the clickOn = cast NewName
updateStage
--waitTicks 30
go to the frame + 1
puppetSprite the clickOn, FALSE
updateStage
--waitTicks 30
end
on BackPageLife
puppetSprite the clickOn, TRUE
set CastNumber = the castNum of sprite the clickOn
set CastName = the name of cast CastNumber
set NumChars = the number of chars in CastName
set ShortChars = NumChars - 2
set NewName = char 1 to ShortChars of CastName & "in"
set the castNum of sprite the clickOn = cast NewName
updateStage
--waitTicks 30
go to the frame - 1
puppetSprite the clickOn, FALSE
updateStage
--waitTicks 30
end